package com.sitanyun.merchant.guide.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sitanyun.merchant.guide.R;
import com.sitanyun.merchant.guide.bean.MessagesBean;

import java.util.ArrayList;

/**
 * Created by jzl
 * on 2022/1/21.
 * 接听弹窗列表
 */
public class DialogActivityListAdatper extends BaseAdapter {
  private ArrayList<MessagesBean> messagesBeans;
  private Context context;
  private int positions =0;
    public DialogActivityListAdatper(ArrayList<MessagesBean> messagesBeans, Context context) {
        this.messagesBeans = messagesBeans;
        this.context = context;
    }
  /*
   * 用于设置当前位置
   */
  public  void setPosition(int position) {
    this.positions = position;
  }
    @Override
    public int getCount() {
        return messagesBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return messagesBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      convertView=  LayoutInflater.from(context).inflate(R.layout.userlist_item,null);
      ImageView headerimg= (ImageView)  convertView.findViewById(R.id.headImage);
        TextView   cname=  (TextView) convertView.findViewById(R.id.c_name);
        TextView cmessage= (TextView)convertView.findViewById(R.id.c_message);
      ImageView idselect=(ImageView) convertView.findViewById(R.id.id_select);
        Glide.with(context).load(messagesBeans.get(position).getHeadUrl()).into(headerimg);
        cname.setText(messagesBeans.get(position).getCName());
        cmessage.setText("申请同屏讲解"+messagesBeans.get(position).getStoreName());
      if (positions == position) {
    Glide.with(context).load(R.mipmap.cbxz).into(idselect);
      } else {
        Glide.with(context).load(R.mipmap.cbwx).into(idselect);
      }
        return convertView;
    }
}
